package com.data.modules.wrt.service.impl;


import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.data.modules.wrt.entity.WrtRoom;
import com.data.modules.wrt.entity.WrtUserInfo;
import com.data.modules.wrt.mapper.WrtRoomMapper;
import com.data.modules.wrt.mapper.WrtUserInfoMapper;
import com.data.modules.wrt.service.IWrtUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 慧锐通用户信息
 * @Author: data-boot
 * @Date:   2023-10-09
 * @Version: V1.0
 */
@Service
public class WrtUserInfoServiceImpl extends ServiceImpl<WrtUserInfoMapper, WrtUserInfo> implements IWrtUserInfoService {

    @Autowired
    private WrtUserInfoMapper wrtUserInfoMapper;
    @Override
    public void saveUserInfo(List<WrtUserInfo> list) {

        list.stream().forEach(x->{

            LambdaQueryWrapper<WrtUserInfo> lambdaQueryWrapper = new QueryWrapper<WrtUserInfo>()
                    .lambda();
            lambdaQueryWrapper.eq(WrtUserInfo::getSn,x.getSn());
            List<WrtUserInfo> users = baseMapper.selectList(lambdaQueryWrapper);
            if(ObjectUtil.isEmpty(users)){
                this.wrtUserInfoMapper.insert(x);
            }
        });

    }
}
